<template>
  <div id="box">
    <myHeader v-show="showHeader" />
    <!-- 需要缓存的视图组件 -->
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <!-- 不需要缓存的视图组件 -->
    <router-view v-if="!$route.meta.keepAlive"></router-view>
    <myFooter v-show="showFooter" />
  </div>
</template>

<script>
import { getTempToken } from "@/utils/token.js";

import myHeader from "@/components/Header";
import myFooter from "@/components/Footer";

export default {
  name: "App",
  components: { myHeader, myFooter },
  computed: {
    showFooter() {
      const { showFooter } = this.$route.meta;
      return showFooter != undefined ? showFooter : true; //获取路由meta配置项判断是否展示footer组件
    },
    showHeader() {
      const { showHeader } = this.$route.meta;
      return showHeader != undefined ? showHeader : true; //获取路由meta配置项判断是否展示Header组件
    },
  },
  methods: {
    getCategoryList() {
      this.$store.dispatch("home/getCategoryList"); //通过actions 获取categoryList列表数据
    },
  },
  mounted() {
    this.getCategoryList();
    getTempToken(); //获取临时Token
  },
};
</script>

<style lang="less">
#nprogress .bar {
  height: 4px !important;
  background: #3498db !important;
}
@font-face {
  font-family: "iconfont"; /* Project id 3149075 */
  src: url("//at.alicdn.com/t/font_3149075_q5luw9sxadq.woff2?t=1642748356220")
      format("woff2"),
    url("//at.alicdn.com/t/font_3149075_q5luw9sxadq.woff?t=1642748356220")
      format("woff"),
    url("//at.alicdn.com/t/font_3149075_q5luw9sxadq.ttf?t=1642748356220")
      format("truetype");
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-money:before {
  content: "\e63f";
}

.icon-hook:before {
  content: "\e8bd";
}

.icon-dots:before {
  content: "\e708";
}

.icon-pre:before {
  content: "\e64c";
}

.icon-next:before {
  content: "\e64e";
}

.icon-desc:before {
  content: "\e64a";
}

.icon-asc:before {
  content: "\e64d";
}
</style>
